home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 January / PCWorld_2007-01_cd.bin / v cisle / hotkey / AutoHotkey104504_Install.exe / AutoHotkey.chm / docs / scripts / numpadmouse.ahk < prev    next >
Text File  |  2006-11-15  |  21KB  |  750 lines

  1. ; Using Keyboard Numpad as a Mouse -- by deguix
  2. ; http://www.autohotkey.com
  3. ; This script makes mousing with your keyboard almost as easy
  4. ; as using a real mouse (maybe even easier for some tasks).
  5. ; It supports up to five mouse buttons and the turning of the
  6. ; mouse wheel.  It also features customizable movement speed,
  7. ; acceleration, and "axis inversion".
  8.  
  9. /*
  10. o------------------------------------------------------------o
  11. |Using Keyboard Numpad as a Mouse                            |
  12. (------------------------------------------------------------)
  13. | By deguix           / A Script file for AutoHotkey 1.0.22+ |
  14. |                    ----------------------------------------|
  15. |                                                            |
  16. |    This script is an example of use of AutoHotkey. It uses |
  17. | the remapping of numpad keys of a keyboard to transform it |
  18. | into a mouse. Some features are the acceleration which     |
  19. | enables you to increase the mouse movement when holding    |
  20. | a key for a long time, and the rotation which makes the    |
  21. | numpad mouse to "turn". I.e. NumPadDown as NumPadUp        |
  22. | and vice-versa. See the list of keys used below:           |
  23. |                                                            |
  24. |------------------------------------------------------------|
  25. | Keys                  | Description                        |
  26. |------------------------------------------------------------|
  27. | ScrollLock (toggle on)| Activates numpad mouse mode.       |
  28. |-----------------------|------------------------------------|
  29. | NumPad0               | Left mouse button click.           |
  30. | NumPad5               | Middle mouse button click.         |
  31. | NumPadDot             | Right mouse button click.          |
  32. | NumPadDiv/NumPadMult  | X1/X2 mouse button click. (Win 2k+)|
  33. | NumPadSub/NumPadAdd   | Moves up/down the mouse wheel.     |
  34. |                       |                                    |
  35. |-----------------------|------------------------------------|
  36. | NumLock (toggled off) | Activates mouse movement mode.     |
  37. |-----------------------|------------------------------------|
  38. | NumPadEnd/Down/PgDn/  | Mouse movement.                    |
  39. | /Left/Right/Home/Up/  |                                    |
  40. | /PgUp                 |                                    |
  41. |                       |                                    |
  42. |-----------------------|------------------------------------|
  43. | NumLock (toggled on)  | Activates mouse speed adj. mode.   |
  44. |-----------------------|------------------------------------|
  45. | NumPad7/NumPad1       | Inc./dec. acceleration per         |
  46. |                       | button press.                      |
  47. | NumPad8/NumPad2       | Inc./dec. initial speed per        |
  48. |                       | button press.                      |
  49. | NumPad9/NumPad3       | Inc./dec. maximum speed per        |
  50. |                       | button press.                      |
  51. | ^NumPad7/^NumPad1     | Inc./dec. wheel acceleration per   |
  52. |                       | button press*.                     |
  53. | ^NumPad8/^NumPad2     | Inc./dec. wheel initial speed per  |
  54. |                       | button press*.                     |
  55. | ^NumPad9/^NumPad3     | Inc./dec. wheel maximum speed per  |
  56. |                       | button press*.                     |
  57. | NumPad4/NumPad6       | Inc./dec. rotation angle to        |
  58. |                       | right in degrees. (i.e. 180░ =     |
  59. |                       | = inversed controls).              |
  60. |------------------------------------------------------------|
  61. | * = These options are affected by the mouse wheel speed    |
  62. | adjusted on Control Panel. If you don't have a mouse with  |
  63. | wheel, the default is 3 +/- lines per option button press. |
  64. o------------------------------------------------------------o
  65. */
  66.  
  67. ;START OF CONFIG SECTION
  68.  
  69. #SingleInstance force
  70. #MaxHotkeysPerInterval 500
  71.  
  72. ; Using the keyboard hook to implement the Numpad hotkeys prevents
  73. ; them from interfering with the generation of ANSI characters such
  74. ; as α.  This is because AutoHotkey generates such characters
  75. ; by holding down ALT and sending a series of Numpad keystrokes.
  76. ; Hook hotkeys are smart enough to ignore such keystrokes.
  77. #UseHook
  78.  
  79. MouseSpeed = 1
  80. MouseAccelerationSpeed = 1
  81. MouseMaxSpeed = 5
  82.  
  83. ;Mouse wheel speed is also set on Control Panel. As that
  84. ;will affect the normal mouse behavior, the real speed of
  85. ;these three below are times the normal mouse wheel speed.
  86. MouseWheelSpeed = 1
  87. MouseWheelAccelerationSpeed = 1
  88. MouseWheelMaxSpeed = 5
  89.  
  90. MouseRotationAngle = 0
  91.  
  92. ;END OF CONFIG SECTION
  93.  
  94. ;This is needed or key presses would faulty send their natural
  95. ;actions. Like NumPadDiv would send sometimes "/" to the
  96. ;screen.       
  97. #InstallKeybdHook
  98.  
  99. Temp = 0
  100. Temp2 = 0
  101.  
  102. MouseRotationAnglePart = %MouseRotationAngle%
  103. ;Divide by 45║ because MouseMove only supports whole numbers,
  104. ;and changing the mouse rotation to a number lesser than 45║
  105. ;could make strange movements.
  106. ;
  107. ;For example: 22.5║ when pressing NumPadUp:
  108. ;  First it would move upwards until the speed
  109. ;  to the side reaches 1.
  110. MouseRotationAnglePart /= 45
  111.  
  112. MouseCurrentAccelerationSpeed = 0
  113. MouseCurrentSpeed = %MouseSpeed%
  114.  
  115. MouseWheelCurrentAccelerationSpeed = 0
  116. MouseWheelCurrentSpeed = %MouseSpeed%
  117.  
  118. SetKeyDelay, -1
  119. SetMouseDelay, -1
  120.  
  121. Hotkey, *NumPad0, ButtonLeftClick
  122. Hotkey, *NumpadIns, ButtonLeftClickIns
  123. Hotkey, *NumPad5, ButtonMiddleClick
  124. Hotkey, *NumpadClear, ButtonMiddleClickClear
  125. Hotkey, *NumPadDot, ButtonRightClick
  126. Hotkey, *NumPadDel, ButtonRightClickDel
  127. Hotkey, *NumPadDiv, ButtonX1Click
  128. Hotkey, *NumPadMult, ButtonX2Click
  129.  
  130. Hotkey, *NumpadSub, ButtonWheelUp
  131. Hotkey, *NumpadAdd, ButtonWheelDown
  132.  
  133. Hotkey, *NumPadUp, ButtonUp
  134. Hotkey, *NumPadDown, ButtonDown
  135. Hotkey, *NumPadLeft, ButtonLeft
  136. Hotkey, *NumPadRight, ButtonRight
  137. Hotkey, *NumPadHome, ButtonUpLeft
  138. Hotkey, *NumPadEnd, ButtonUpRight
  139. Hotkey, *NumPadPgUp, ButtonDownLeft
  140. Hotkey, *NumPadPgDn, ButtonDownRight
  141.  
  142. Hotkey, Numpad8, ButtonSpeedUp
  143. Hotkey, Numpad2, ButtonSpeedDown
  144. Hotkey, Numpad7, ButtonAccelerationSpeedUp
  145. Hotkey, Numpad1, ButtonAccelerationSpeedDown
  146. Hotkey, Numpad9, ButtonMaxSpeedUp
  147. Hotkey, Numpad3, ButtonMaxSpeedDown
  148.  
  149. Hotkey, Numpad6, ButtonRotationAngleUp
  150. Hotkey, Numpad4, ButtonRotationAngleDown
  151.  
  152. Hotkey, !Numpad8, ButtonWheelSpeedUp
  153. Hotkey, !Numpad2, ButtonWheelSpeedDown
  154. Hotkey, !Numpad7, ButtonWheelAccelerationSpeedUp
  155. Hotkey, !Numpad1, ButtonWheelAccelerationSpeedDown
  156. Hotkey, !Numpad9, ButtonWheelMaxSpeedUp
  157. Hotkey, !Numpad3, ButtonWheelMaxSpeedDown
  158.  
  159. Gosub, ~ScrollLock  ; Initialize based on current ScrollLock state.
  160. return
  161.  
  162. ;Key activation support
  163.  
  164. ~ScrollLock::
  165. ; Wait for it to be released because otherwise the hook state gets reset
  166. ; while the key is down, which causes the up-event to get suppressed,
  167. ; which in turn prevents toggling of the ScrollLock state/light:
  168. KeyWait, ScrollLock
  169. GetKeyState, ScrollLockState, ScrollLock, T
  170. If ScrollLockState = D
  171. {
  172.     Hotkey, *NumPad0, on
  173.     Hotkey, *NumpadIns, on
  174.     Hotkey, *NumPad5, on
  175.     Hotkey, *NumPadDot, on
  176.     Hotkey, *NumPadDel, on
  177.     Hotkey, *NumPadDiv, on
  178.     Hotkey, *NumPadMult, on
  179.  
  180.     Hotkey, *NumpadSub, on
  181.     Hotkey, *NumpadAdd, on
  182.  
  183.     Hotkey, *NumPadUp, on
  184.     Hotkey, *NumPadDown, on
  185.     Hotkey, *NumPadLeft, on
  186.     Hotkey, *NumPadRight, on
  187.     Hotkey, *NumPadHome, on
  188.     Hotkey, *NumPadEnd, on
  189.     Hotkey, *NumPadPgUp, on
  190.     Hotkey, *NumPadPgDn, on
  191.  
  192.     Hotkey, Numpad8, on
  193.     Hotkey, Numpad2, on
  194.     Hotkey, Numpad7, on
  195.     Hotkey, Numpad1, on
  196.     Hotkey, Numpad9, on
  197.     Hotkey, Numpad3, on
  198.  
  199.     Hotkey, Numpad6, on
  200.     Hotkey, Numpad4, on
  201.  
  202.     Hotkey, !Numpad8, on
  203.     Hotkey, !Numpad2, on
  204.     Hotkey, !Numpad7, on
  205.     Hotkey, !Numpad1, on
  206.     Hotkey, !Numpad9, on
  207.     Hotkey, !Numpad3, on
  208. }
  209. else
  210. {
  211.     Hotkey, *NumPad0, off
  212.     Hotkey, *NumpadIns, off
  213.     Hotkey, *NumPad5, off
  214.     Hotkey, *NumPadDot, off
  215.     Hotkey, *NumPadDel, off
  216.     Hotkey, *NumPadDiv, off
  217.     Hotkey, *NumPadMult, off
  218.  
  219.     Hotkey, *NumpadSub, off
  220.     Hotkey, *NumpadAdd, off
  221.  
  222.     Hotkey, *NumPadUp, off
  223.     Hotkey, *NumPadDown, off
  224.     Hotkey, *NumPadLeft, off
  225.     Hotkey, *NumPadRight, off
  226.     Hotkey, *NumPadHome, off
  227.     Hotkey, *NumPadEnd, off
  228.     Hotkey, *NumPadPgUp, off
  229.     Hotkey, *NumPadPgDn, off
  230.  
  231.     Hotkey, Numpad8, off
  232.     Hotkey, Numpad2, off
  233.     Hotkey, Numpad7, off
  234.     Hotkey, Numpad1, off
  235.     Hotkey, Numpad9, off
  236.     Hotkey, Numpad3, off
  237.  
  238.     Hotkey, Numpad6, off
  239.     Hotkey, Numpad4, off
  240.  
  241.     Hotkey, !Numpad8, off
  242.     Hotkey, !Numpad2, off
  243.     Hotkey, !Numpad7, off
  244.     Hotkey, !Numpad1, off
  245.     Hotkey, !Numpad9, off
  246.     Hotkey, !Numpad3, off
  247. }
  248. return
  249.  
  250. ;Mouse click support
  251.  
  252. ButtonLeftClick:
  253. GetKeyState, already_down_state, LButton
  254. If already_down_state = D
  255.     return
  256. Button2 = NumPad0
  257. ButtonClick = Left
  258. Goto ButtonClickStart
  259. ButtonLeftClickIns:
  260. GetKeyState, already_down_state, LButton
  261. If already_down_state = D
  262.     return
  263. Button2 = NumPadIns
  264. ButtonClick = Left
  265. Goto ButtonClickStart
  266.  
  267. ButtonMiddleClick:
  268. GetKeyState, already_down_state, MButton
  269. If already_down_state = D
  270.     return
  271. Button2 = NumPad5
  272. ButtonClick = Middle
  273. Goto ButtonClickStart
  274. ButtonMiddleClickClear:
  275. GetKeyState, already_down_state, MButton
  276. If already_down_state = D
  277.     return
  278. Button2 = NumPadClear
  279. ButtonClick = Middle
  280. Goto ButtonClickStart
  281.  
  282. ButtonRightClick:
  283. GetKeyState, already_down_state, RButton
  284. If already_down_state = D
  285.     return
  286. Button2 = NumPadDot
  287. ButtonClick = Right
  288. Goto ButtonClickStart
  289. ButtonRightClickDel:
  290. GetKeyState, already_down_state, RButton
  291. If already_down_state = D
  292.     return
  293. Button2 = NumPadDel
  294. ButtonClick = Right
  295. Goto ButtonClickStart
  296.  
  297. ButtonX1Click:
  298. GetKeyState, already_down_state, XButton1
  299. If already_down_state = D
  300.     return
  301. Button2 = NumPadDiv
  302. ButtonClick = X1
  303. Goto ButtonClickStart
  304.  
  305. ButtonX2Click:
  306. GetKeyState, already_down_state, XButton2
  307. If already_down_state = D
  308.     return
  309. Button2 = NumPadMult
  310. ButtonClick = X2
  311. Goto ButtonClickStart
  312.  
  313. ButtonClickStart:
  314. MouseClick, %ButtonClick%,,, 1, 0, D
  315. SetTimer, ButtonClickEnd, 10
  316. return
  317.  
  318. ButtonClickEnd:
  319. GetKeyState, kclickstate, %Button2%, P
  320. if kclickstate = D
  321.     return
  322.  
  323. SetTimer, ButtonClickEnd, off
  324. MouseClick, %ButtonClick%,,, 1, 0, U
  325. return
  326.  
  327. ;Mouse movement support
  328.  
  329. ButtonSpeedUp:
  330. MouseSpeed++
  331. ToolTip, Mouse speed: %MouseSpeed% pixels
  332. SetTimer, RemoveToolTip, 1000
  333. return
  334. ButtonSpeedDown:
  335. If MouseSpeed > 1
  336.     MouseSpeed--
  337. If MouseSpeed = 1
  338.     ToolTip, Mouse speed: %MouseSpeed% pixel
  339. else
  340.     ToolTip, Mouse speed: %MouseSpeed% pixels
  341. SetTimer, RemoveToolTip, 1000
  342. return
  343. ButtonAccelerationSpeedUp:
  344. MouseAccelerationSpeed++
  345. ToolTip, Mouse acceleration speed: %MouseAccelerationSpeed% pixels
  346. SetTimer, RemoveToolTip, 1000
  347. return
  348. ButtonAccelerationSpeedDown:
  349. If MouseAccelerationSpeed > 1
  350.     MouseAccelerationSpeed--
  351. If MouseAccelerationSpeed = 1
  352.     ToolTip, Mouse acceleration speed: %MouseAccelerationSpeed% pixel
  353. else
  354.     ToolTip, Mouse acceleration speed: %MouseAccelerationSpeed% pixels
  355. SetTimer, RemoveToolTip, 1000
  356. return
  357.  
  358. ButtonMaxSpeedUp:
  359. MouseMaxSpeed++
  360. ToolTip, Mouse maximum speed: %MouseMaxSpeed% pixels
  361. SetTimer, RemoveToolTip, 1000
  362. return
  363. ButtonMaxSpeedDown:
  364. If MouseMaxSpeed > 1
  365.     MouseMaxSpeed--
  366. If MouseMaxSpeed = 1
  367.     ToolTip, Mouse maximum speed: %MouseMaxSpeed% pixel
  368. else
  369.     ToolTip, Mouse maximum speed: %MouseMaxSpeed% pixels
  370. SetTimer, RemoveToolTip, 1000
  371. return
  372.  
  373. ButtonRotationAngleUp:
  374. MouseRotationAnglePart++
  375. If MouseRotationAnglePart >= 8
  376.     MouseRotationAnglePart = 0
  377. MouseRotationAngle = %MouseRotationAnglePart%
  378. MouseRotationAngle *= 45
  379. ToolTip, Mouse rotation angle: %MouseRotationAngle%░
  380. SetTimer, RemoveToolTip, 1000
  381. return
  382. ButtonRotationAngleDown:
  383. MouseRotationAnglePart--
  384. If MouseRotationAnglePart < 0
  385.     MouseRotationAnglePart = 7
  386. MouseRotationAngle = %MouseRotationAnglePart%
  387. MouseRotationAngle *= 45
  388. ToolTip, Mouse rotation angle: %MouseRotationAngle%░
  389. SetTimer, RemoveToolTip, 1000
  390. return
  391.  
  392. ButtonUp:
  393. ButtonDown:
  394. ButtonLeft:
  395. ButtonRight:
  396. ButtonUpLeft:
  397. ButtonUpRight:
  398. ButtonDownLeft:
  399. ButtonDownRight:
  400. If Button <> 0
  401. {
  402.     IfNotInString, A_ThisHotkey, %Button%
  403.     {
  404.         MouseCurrentAccelerationSpeed = 0
  405.         MouseCurrentSpeed = %MouseSpeed%
  406.     }
  407. }
  408. StringReplace, Button, A_ThisHotkey, *
  409.  
  410. ButtonAccelerationStart:
  411. If MouseAccelerationSpeed >= 1
  412. {
  413.     If MouseMaxSpeed > %MouseCurrentSpeed%
  414.     {
  415.         Temp = 0.001
  416.         Temp *= %MouseAccelerationSpeed%
  417.         MouseCurrentAccelerationSpeed += %Temp%
  418.         MouseCurrentSpeed += %MouseCurrentAccelerationSpeed%
  419.     }
  420. }
  421.  
  422. ;MouseRotationAngle convertion to speed of button direction
  423. {
  424.     MouseCurrentSpeedToDirection = %MouseRotationAngle%
  425.     MouseCurrentSpeedToDirection /= 90.0
  426.     Temp = %MouseCurrentSpeedToDirection%
  427.  
  428.     if Temp >= 0
  429.     {
  430.         if Temp < 1
  431.         {
  432.             MouseCurrentSpeedToDirection = 1
  433.             MouseCurrentSpeedToDirection -= %Temp%
  434.             Goto EndMouseCurrentSpeedToDirectionCalculation
  435.         }
  436.     }
  437.     if Temp >= 1
  438.     {
  439.         if Temp < 2
  440.         {
  441.             MouseCurrentSpeedToDirection = 0
  442.             Temp -= 1
  443.             MouseCurrentSpeedToDirection -= %Temp%
  444.             Goto EndMouseCurrentSpeedToDirectionCalculation
  445.         }
  446.     }
  447.     if Temp >= 2
  448.     {
  449.         if Temp < 3
  450.         {
  451.             MouseCurrentSpeedToDirection = -1
  452.             Temp -= 2
  453.             MouseCurrentSpeedToDirection += %Temp%
  454.             Goto EndMouseCurrentSpeedToDirectionCalculation
  455.         }
  456.     }
  457.     if Temp >= 3
  458.     {
  459.         if Temp < 4
  460.         {
  461.             MouseCurrentSpeedToDirection = 0
  462.             Temp -= 3
  463.             MouseCurrentSpeedToDirection += %Temp%
  464.             Goto EndMouseCurrentSpeedToDirectionCalculation
  465.         }
  466.     }
  467. }
  468. EndMouseCurrentSpeedToDirectionCalculation:
  469.  
  470. ;MouseRotationAngle convertion to speed of 90 degrees to right
  471. {
  472.     MouseCurrentSpeedToSide = %MouseRotationAngle%
  473.     MouseCurrentSpeedToSide /= 90.0
  474.     Temp = %MouseCurrentSpeedToSide%
  475.     Transform, Temp, mod, %Temp%, 4
  476.  
  477.     if Temp >= 0
  478.     {
  479.         if Temp < 1
  480.         {
  481.             MouseCurrentSpeedToSide = 0
  482.             MouseCurrentSpeedToSide += %Temp%
  483.             Goto EndMouseCurrentSpeedToSideCalculation
  484.         }
  485.     }
  486.     if Temp >= 1
  487.     {
  488.         if Temp < 2
  489.         {
  490.             MouseCurrentSpeedToSide = 1
  491.             Temp -= 1
  492.             MouseCurrentSpeedToSide -= %Temp%
  493.             Goto EndMouseCurrentSpeedToSideCalculation
  494.         }
  495.     }
  496.     if Temp >= 2
  497.     {
  498.         if Temp < 3
  499.         {
  500.             MouseCurrentSpeedToSide = 0
  501.             Temp -= 2
  502.             MouseCurrentSpeedToSide -= %Temp%
  503.             Goto EndMouseCurrentSpeedToSideCalculation
  504.         }
  505.     }
  506.     if Temp >= 3
  507.     {
  508.         if Temp < 4
  509.         {
  510.             MouseCurrentSpeedToSide = -1
  511.             Temp -= 3
  512.             MouseCurrentSpeedToSide += %Temp%
  513.             Goto EndMouseCurrentSpeedToSideCalculation
  514.         }
  515.     }
  516. }
  517. EndMouseCurrentSpeedToSideCalculation:
  518.  
  519. MouseCurrentSpeedToDirection *= %MouseCurrentSpeed%
  520. MouseCurrentSpeedToSide *= %MouseCurrentSpeed%
  521.  
  522. Temp = %MouseRotationAnglePart%
  523. Transform, Temp, Mod, %Temp%, 2
  524.  
  525. If Button = NumPadUp
  526. {
  527.     if Temp = 1
  528.     {
  529.         MouseCurrentSpeedToSide *= 2
  530.         MouseCurrentSpeedToDirection *= 2
  531.     }
  532.  
  533.     MouseCurrentSpeedToDirection *= -1
  534.     MouseMove, %MouseCurrentSpeedToSide%, %MouseCurrentSpeedToDirection%, 0, R
  535. }
  536. else if Button = NumPadDown
  537. {
  538.     if Temp = 1
  539.     {
  540.         MouseCurrentSpeedToSide *= 2
  541.         MouseCurrentSpeedToDirection *= 2
  542.     }
  543.  
  544.     MouseCurrentSpeedToSide *= -1
  545.     MouseMove, %MouseCurrentSpeedToSide%, %MouseCurrentSpeedToDirection%, 0, R
  546. }
  547. else if Button = NumPadLeft
  548. {
  549.     if Temp = 1
  550.     {
  551.         MouseCurrentSpeedToSide *= 2
  552.         MouseCurrentSpeedToDirection *= 2
  553.     }
  554.  
  555.     MouseCurrentSpeedToSide *= -1
  556.     MouseCurrentSpeedToDirection *= -1
  557.     MouseMove, %MouseCurrentSpeedToDirection%, %MouseCurrentSpeedToSide%, 0, R
  558. }
  559. else if Button = NumPadRight
  560. {
  561.     if Temp = 1
  562.     {
  563.         MouseCurrentSpeedToSide *= 2
  564.         MouseCurrentSpeedToDirection *= 2
  565.     }
  566.  
  567.     MouseMove, %MouseCurrentSpeedToDirection%, %MouseCurrentSpeedToSide%, 0, R
  568. }
  569. else if Button = NumPadHome
  570. {
  571.     Temp = %MouseCurrentSpeedToDirection%
  572.     Temp -= %MouseCurrentSpeedToSide%
  573.     Temp *= -1
  574.     Temp2 = %MouseCurrentSpeedToDirection%
  575.     Temp2 += %MouseCurrentSpeedToSide%
  576.     Temp2 *= -1
  577.     MouseMove, %Temp%, %Temp2%, 0, R
  578. }
  579. else if Button = NumPadPgUp
  580. {
  581.     Temp = %MouseCurrentSpeedToDirection%
  582.     Temp += %MouseCurrentSpeedToSide%
  583.     Temp2 = %MouseCurrentSpeedToDirection%
  584.     Temp2 -= %MouseCurrentSpeedToSide%
  585.     Temp2 *= -1
  586.     MouseMove, %Temp%, %Temp2%, 0, R
  587. }
  588. else if Button = NumPadEnd
  589. {
  590.     Temp = %MouseCurrentSpeedToDirection%
  591.     Temp += %MouseCurrentSpeedToSide%
  592.     Temp *= -1
  593.     Temp2 = %MouseCurrentSpeedToDirection%
  594.     Temp2 -= %MouseCurrentSpeedToSide%
  595.     MouseMove, %Temp%, %Temp2%, 0, R
  596. }
  597. else if Button = NumPadPgDn
  598. {
  599.     Temp = %MouseCurrentSpeedToDirection%
  600.     Temp -= %MouseCurrentSpeedToSide%
  601.     Temp2 *= -1
  602.     Temp2 = %MouseCurrentSpeedToDirection%
  603.     Temp2 += %MouseCurrentSpeedToSide%
  604.     MouseMove, %Temp%, %Temp2%, 0, R
  605. }
  606.  
  607. SetTimer, ButtonAccelerationEnd, 10
  608. return
  609.  
  610. ButtonAccelerationEnd:
  611. GetKeyState, kstate, %Button%, P
  612. if kstate = D
  613.     Goto ButtonAccelerationStart
  614.  
  615. SetTimer, ButtonAccelerationEnd, off
  616. MouseCurrentAccelerationSpeed = 0
  617. MouseCurrentSpeed = %MouseSpeed%
  618. Button = 0
  619. return
  620.  
  621. ;Mouse wheel movement support
  622.  
  623. ButtonWheelSpeedUp:
  624. MouseWheelSpeed++
  625. RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
  626. If MouseWheelSpeedMultiplier <= 0
  627.     MouseWheelSpeedMultiplier = 1
  628. MouseWheelSpeedReal = %MouseWheelSpeed%
  629. MouseWheelSpeedReal *= %MouseWheelSpeedMultiplier%
  630. ToolTip, Mouse wheel speed: %MouseWheelSpeedReal% lines
  631. SetTimer, RemoveToolTip, 1000
  632. return
  633. ButtonWheelSpeedDown:
  634. RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
  635. If MouseWheelSpeedMultiplier <= 0
  636.     MouseWheelSpeedMultiplier = 1
  637. If MouseWheelSpeedReal > %MouseWheelSpeedMultiplier%
  638. {
  639.     MouseWheelSpeed--
  640.     MouseWheelSpeedReal = %MouseWheelSpeed%
  641.     MouseWheelSpeedReal *= %MouseWheelSpeedMultiplier%
  642. }
  643. If MouseWheelSpeedReal = 1
  644.     ToolTip, Mouse wheel speed: %MouseWheelSpeedReal% line
  645. else
  646.     ToolTip, Mouse wheel speed: %MouseWheelSpeedReal% lines
  647. SetTimer, RemoveToolTip, 1000
  648. return
  649.  
  650. ButtonWheelAccelerationSpeedUp:
  651. MouseWheelAccelerationSpeed++
  652. RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
  653. If MouseWheelSpeedMultiplier <= 0
  654.     MouseWheelSpeedMultiplier = 1
  655. MouseWheelAccelerationSpeedReal = %MouseWheelAccelerationSpeed%
  656. MouseWheelAccelerationSpeedReal *= %MouseWheelSpeedMultiplier%
  657. ToolTip, Mouse wheel acceleration speed: %MouseWheelAccelerationSpeedReal% lines
  658. SetTimer, RemoveToolTip, 1000
  659. return
  660. ButtonWheelAccelerationSpeedDown:
  661. RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
  662. If MouseWheelSpeedMultiplier <= 0
  663.     MouseWheelSpeedMultiplier = 1
  664. If MouseWheelAccelerationSpeed > 1
  665. {
  666.     MouseWheelAccelerationSpeed--
  667.     MouseWheelAccelerationSpeedReal = %MouseWheelAccelerationSpeed%
  668.     MouseWheelAccelerationSpeedReal *= %MouseWheelSpeedMultiplier%
  669. }
  670. If MouseWheelAccelerationSpeedReal = 1
  671.     ToolTip, Mouse wheel acceleration speed: %MouseWheelAccelerationSpeedReal% line
  672. else
  673.     ToolTip, Mouse wheel acceleration speed: %MouseWheelAccelerationSpeedReal% lines
  674. SetTimer, RemoveToolTip, 1000
  675. return
  676.  
  677. ButtonWheelMaxSpeedUp:
  678. MouseWheelMaxSpeed++
  679. RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
  680. If MouseWheelSpeedMultiplier <= 0
  681.     MouseWheelSpeedMultiplier = 1
  682. MouseWheelMaxSpeedReal = %MouseWheelMaxSpeed%
  683. MouseWheelMaxSpeedReal *= %MouseWheelSpeedMultiplier%
  684. ToolTip, Mouse wheel maximum speed: %MouseWheelMaxSpeedReal% lines
  685. SetTimer, RemoveToolTip, 1000
  686. return
  687. ButtonWheelMaxSpeedDown:
  688. RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
  689. If MouseWheelSpeedMultiplier <= 0
  690.     MouseWheelSpeedMultiplier = 1
  691. If MouseWheelMaxSpeed > 1
  692. {
  693.     MouseWheelMaxSpeed--
  694.     MouseWheelMaxSpeedReal = %MouseWheelMaxSpeed%
  695.     MouseWheelMaxSpeedReal *= %MouseWheelSpeedMultiplier%
  696. }
  697. If MouseWheelMaxSpeedReal = 1
  698.     ToolTip, Mouse wheel maximum speed: %MouseWheelMaxSpeedReal% line
  699. else
  700.     ToolTip, Mouse wheel maximum speed: %MouseWheelMaxSpeedReal% lines
  701. SetTimer, RemoveToolTip, 1000
  702. return
  703.  
  704. ButtonWheelUp:
  705. ButtonWheelDown:
  706.  
  707. If Button <> 0
  708. {
  709.     If Button <> %A_ThisHotkey%
  710.     {
  711.         MouseWheelCurrentAccelerationSpeed = 0
  712.         MouseWheelCurrentSpeed = %MouseWheelSpeed%
  713.     }
  714. }
  715. StringReplace, Button, A_ThisHotkey, *
  716.  
  717. ButtonWheelAccelerationStart:
  718. If MouseWheelAccelerationSpeed >= 1
  719. {
  720.     If MouseWheelMaxSpeed > %MouseWheelCurrentSpeed%
  721.     {
  722.         Temp = 0.001
  723.         Temp *= %MouseWheelAccelerationSpeed%
  724.         MouseWheelCurrentAccelerationSpeed += %Temp%
  725.         MouseWheelCurrentSpeed += %MouseWheelCurrentAccelerationSpeed%
  726.     }
  727. }
  728.  
  729. If Button = NumPadSub
  730.     MouseClick, wheelup,,, %MouseWheelCurrentSpeed%, 0, D
  731. else if Button = NumPadAdd
  732.     MouseClick, wheeldown,,, %MouseWheelCurrentSpeed%, 0, D
  733.  
  734. SetTimer, ButtonWheelAccelerationEnd, 100
  735. return
  736.  
  737. ButtonWheelAccelerationEnd:
  738. GetKeyState, kstate, %Button%, P
  739. if kstate = D
  740.     Goto ButtonWheelAccelerationStart
  741.  
  742. MouseWheelCurrentAccelerationSpeed = 0
  743. MouseWheelCurrentSpeed = %MouseWheelSpeed%
  744. Button = 0
  745. return
  746.  
  747. RemoveToolTip:
  748. SetTimer, RemoveToolTip, Off
  749. ToolTip
  750. return